<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper search-box-cuesList">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="备注">
              <a-input placeholder="请输入备注" v-model="queryParam.remark"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="删除标识0-正常,1-已删除">
              <a-input placeholder="请输入删除标识0-正常,1-已删除" v-model="queryParam.delFlag"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="资源路径">
                <a-input placeholder="请输入资源路径" v-model="queryParam.resourceUrl"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="资源链接路径">
                <a-input placeholder="请输入资源链接路径" v-model="queryParam.linkUrl"></a-input>
              </a-form-item>
            </a-col>
          </template> -->
          <a-col :xl="16" :lg="16" :md="16" :sm="24">
            <a-form-item>
              <!-- <a-input placeholder="请输入广告位置 1、首页 2、活动 3、内容" v-model="queryParam.adPosition"></a-input> -->
              <a-select v-model="queryParam.adPosition" placeholder="请选择" default-value="0" class="select-box">
                <a-select-option value="">全部</a-select-option>
                <a-select-option value="1">采编首页</a-select-option>
                <a-select-option value="2">资讯活动</a-select-option>
                <a-select-option value="3">资讯文章</a-select-option>
                <a-select-option value="4">资讯专题</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search" shape="circle" title="查询"></a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
                shape="circle"
                title="重置"></a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="display:flex;padding-left: 10px; align-items: center;">

        <!-- 操作按钮区域 -->
        <div class="table-operator" style="flex:1;text-align: left;margin-bottom:0">
          <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
          <!-- <a-button type="primary" icon="download" @click="handleExportXls('广告信息')">导出</a-button>
          <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
            <a-button type="primary" icon="import">导入</a-button>
          </a-upload> -->
          <a-dropdown v-if="selectedRowKeys.length > 0">
            <a-menu slot="overlay">
              <a-menu-item key="1" @click="batchDel">
                <a-icon type="delete"/>
                删除
              </a-menu-item>
            </a-menu>
            <a-button style="margin-left: 8px"> 批量操作
              <a-icon type="down"/>
            </a-button>
          </a-dropdown>
        </div>

        <div>
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
          selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>
      </div>

      <a-table
        ref="table"
        size="middle"
        rowKey="id"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <a-table-column title="资源路径" align="center" width="120px">
          <template slot-scope="text, record, index">
            <div style="width: 120px;height: 100px;">
              <img style="width: 100%;height: 100%;" :src="record.resourceUrl"/>
            </div>
          </template>
        </a-table-column>
        <a-table-column title="广告位置" align="center" width="80px" dataIndex="adPosition">
          <template slot-scope="text">
            <span v-if="text==1">采编首页</span>
            <span v-if="text==2">资讯活动</span>
            <span v-if="text==3">资讯文章</span>
            <span v-if="text==4">资讯专题</span>
          </template>
        </a-table-column>
        <a-table-column title="资源链接路径" align="center" dataIndex="linkUrl" width="30%"></a-table-column>
        <a-table-column title="开始时间" align="center" dataIndex="beginDate"></a-table-column>
        <a-table-column title="结束时间" align="center" dataIndex="endDate"></a-table-column>
        <a-table-column title="备注" align="center" dataIndex="remark"></a-table-column>
        <a-table-column title="操作" align="center" width="120px">
          <template slot-scope="text, record">
            <a @click="handleEdit(record)" title="编辑">
              <a-icon type="edit" theme="filled"/>
            </a>
            <a-divider type="vertical"/>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a title="删除">
                <a-icon type="delete" theme="filled" style="color:#ed7770"/>
              </a>
            </a-popconfirm>
          </template>
        </a-table-column>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <baseAdInfo-modal ref="modalForm" @ok="modalFormOk"></baseAdInfo-modal>
  </a-card>
</template>

<script>
  import BaseAdInfoModal from './modules/BaseAdInfoModal'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin';

  export default {
    name: 'BaseAdInfoList',
    mixins: [JeecgListMixin],
    components: {
      BaseAdInfoModal
    },
    data() {
      return {
        description: '广告信息管理页面',
        // 表头
        columns: [{
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
          // {
          //   title: '备注',
          //   align: "center",
          //   dataIndex: 'remark'
          // },
          // {
          //   title: '删除标识0-正常,1-已删除',
          //   align: "center",
          //   dataIndex: 'delFlag'
          // },
          {
            title: '广告位置',
            align: 'center',
            dataIndex: 'adPosition'
          },
          {
            title: '资源路径',
            align: 'center',
            dataIndex: 'resourceUrl'
          },
          {
            title: '资源链接路径',
            align: 'center',
            dataIndex: 'linkUrl',
          },
          {
            title: '开始时间',
            align: 'center',
            dataIndex: 'beginDate'
          },
          {
            title: '结束时间',
            align: 'center',
            dataIndex: 'endDate'
          },
          {
            title: '排序',
            align: 'center',
            dataIndex: 'sort'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],
        url: {
          list: '/base/baseAdInfo/list',
          delete: '/base/baseAdInfo/delete',
          deleteBatch: '/base/baseAdInfo/deleteBatch',
          exportXlsUrl: 'base/baseAdInfo/exportXls',
          importExcelUrl: 'base/baseAdInfo/importExcel'
        }
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    watch: {},
    methods: {}
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
